import { param } from "jquery"

export default {
  props: {
    filterValue: {
      type: Object,
      default: () => { }
    }
  },
  data() {
    return {
    }
  },
  watch: {
    // 根据筛选条件获取统计数据
    filterValue: {
      handler() {
        if (this.getData) {
          // this.getData()
        }
      },
      deep: true
    }
  },
  mounted() {
    // 根据窗口的大小变化实时调整 chart 大小
    this.$bus.on('window-resize', () => {
      if (this.chartObj) {
        this.chartObj.resize()
      }
    })

    if (this.getData) {
      this.getData()
    }
  },
  beforeDestroy() {
    this.$bus.off('window-resize')
  },
  methods: {
    /**
     * 获取请求参数
     */
    getBaseParams() {
      const params = {}
      console.log(this.filterValue, '(this.filterValue(this.filterValue');
      params.dataForm = this.filterValue.dataForm == 1 ? '涵品' : '有成'
      if (this.filterValue.deptIdArray.length > 0) {
        delete this.filterValue.timeLine
        params.dataType = 7
        params.deptIdArray = this.filterValue.deptIdArray



      } else {

        if (this.filterValue.timeLine) {
          if (this.filterValue.timeLine.type === 'custom') {
            params.startTime = this.filterValue.timeLine.startTime.replace(/\./g, '-')
            params.endTime = this.filterValue.timeLine.endTime.replace(/\./g, '-')
          } else {
            params.type = this.filterValue.timeLine.value || ''
          }
        }
      }
      if (this.filterValue.userArray.length > 0) {
        params.dataType = 8
        params.userArray = this.filterValue.userArray
      }
      if (this.filterValue.categoriesVal)
        params.categories = this.filterValue.categoriesVal || "";
      if (this.filterValue.salesTypeVal)
        params.salesType = this.filterValue.salesTypeVal || "";
      if (this.filterValue.repetitionVal)
        params.repetition = this.filterValue.repetitionVal || "";
      if (this.filterValue.hqdateVal) {
        params.startTime = this.filterValue.hqdateVal[0] + " 00:00:00" || "";
        params.endTime = this.filterValue.hqdateVal[1] + " 23:59:59" || "";
      }


      console.log('chartMixin', params)
      return params
    }
  }
}
